package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.view.View;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.bean.WaitTrackBean;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;

/**
 * Created by yidong on 2017/8/8.
 */

public class ClueAdapter extends CommonAdapter<WaitTrackBean.ListBean> {
    private boolean showBtn = false;
    private createOrderListener orderListener;

    public ClueAdapter(Context context, int layoutId, List<WaitTrackBean.ListBean> datas) {
        super(context, layoutId, datas);
    }

    public void setShowBtn(boolean isShow) {
        showBtn = isShow;
    }

    @Override
    protected void convertView(ViewHolder holder, WaitTrackBean.ListBean bean, final int position) {
//        if (TextUtils.isEmpty(bean.getTime_type())) {
//            holder.setVisible(R.id.tv_time_flag, false);
//        } else {
//            switch (Integer.valueOf(bean.getTime_type())) {
//                case 1:
//                    holder.setText(R.id.tv_time_flag, "今");
//                    break;
//                case 2:
//                    holder.setText(R.id.tv_time_flag, "明");
//                    break;
//                case 3:
//                    holder.setText(R.id.tv_time_flag, "后");
//                    break;
//            }
//        }

        holder.setText(R.id.tv_dis_status, bean.getDispatch_status());
        holder.setText(R.id.cc_name, bean.getTou_name() + "(订单号" + bean.getDispatch_id() + ")");
        holder.setText(R.id.tour_level, bean.getTour_level());
        holder.setText(R.id.tv_car_name, bean.getTitle());
        holder.setText(R.id.tv_dealer_name, bean.getDealer_name());
        holder.setText(R.id.tv_dealer_address, bean.getDealer_address());
        holder.setText(R.id.tv_car_id, bean.getCar_id());
//        holder.setText(R.id.tv_update_time, bean.getUpdate_time());
//        holder.setVisible(R.id.tv_create_order, showBtn);
        holder.setOnClickListener(R.id.tv_create_order, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (orderListener != null) {
                    orderListener.createDispatch(mDatas.get(position).getDispatch_id());
                }
            }
        });
        holder.setOnClickListener(R.id.tour_level, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (orderListener != null) {
                    orderListener.editTourLevel(mDatas.get(position).getDispatch_id());
                }
            }
        });

    }

    public void setOrderListener(createOrderListener listener) {
        orderListener = listener;
    }
    public interface createOrderListener {
        void createDispatch(String dispatch_id);
        void editTourLevel(String dispatch_id);

    }
}
